<?php

namespace core;

class zhixing{
	static $classMap = [];

	static public function run(){
		$route = new \core\lib\route();
		$ctrl = $route->ctrl;
		$action = $route->action;
		$ctrlFile = APP.'/controller'.$ctrl.'Controller.php';
		if(is_file($ctrlFile)){
			include $ctrlFile;
			new MODULE.'/controller'.$ctrl();
		} else {
			throw new \Exception('找不到控制器'.$ctrl);
		}
		//ddd($route);
	}

	//自动加载类库
	static public function load($class){
		if(isset($classMap[$class])){
			return true;
		} else {
			$class = str_replace('\\', '/', $class);
			$file = ZHIXING.'/'.$class.'.php';
			if(is_file($file)){
				include $file;
				self::$classMap[$class] = $class;
			} else {
				return false;
			}
		}
	}
}